package com.study4j.crontab.task;

import org.quartz.Job;
import org.quartz.JobDataMap;
import org.quartz.JobDetail;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.study4j.common.model.ResultModel;
import com.study4j.crontab.rpc.IRabbitMQService;

import cn.hutool.core.date.DateTime;

@Component
public class TestQuartz implements Job {
	
	@Autowired
	private IRabbitMQService rabbitMQService;
	
    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
    	//获取任务名
        String taskName = context.getJobDetail().getKey().getName();
        JobDetail jobDetail = context.getJobDetail();
        JobDataMap jobDataMap = jobDetail.getJobDataMap();
        //处理执行任务之后的业务
        System.out.println("-------------------------测试定时任务，执行时间："+DateTime.now()+"--------------------------------");
        ResultModel rabbitMQInit = rabbitMQService.rabbitMQInit();
        System.out.println(rabbitMQInit);
        System.out.println(context);
    }
}

